package com.duoec.dw.lineage.service.impl.analyser.statement;

import com.alibaba.druid.sql.ast.statement.SQLUseStatement;
import com.duoec.dw.lineage.core.utils.AnalyserUtils;
import org.springframework.stereotype.Service;

/**
 * @author xuwenzhen
 */
@Service
public class MySqlUseStatementAnalyser extends BaseStatementAnalyser<SQLUseStatement, String> {
    /**
     * 获取当前分析器分析的statement类型
     *
     * @return statement类型
     */
    @Override
    public Class<SQLUseStatement> getType() {
        return SQLUseStatement.class;
    }

    /**
     * 解析语句
     *
     * @param statement SQL语句
     * @return 返回值
     */
    @Override
    public String analyse(SQLUseStatement statement) {
        return AnalyserUtils.formatFieldName(statement.getDatabase().getSimpleName());
    }
}
